Skip to content

feat: add AI provider abstraction layer for Anthropic, Groq and Gemini#89

Merged
Vishnu2707 merged 4 commits into
devfrom
feat/ai-provider-layer
May 29, 2026
Merged

feat: add AI provider abstraction layer for Anthropic, Groq and Gemini#89
Vishnu2707 merged 4 commits into
devfrom
feat/ai-provider-layer

Conversation

@TFT444
Copy link
Copy Markdown
Collaborator

@TFT444 TFT444 commented May 29, 2026

What does this PR do?

Adds the AI provider abstraction layer that handles communication with Anthropic, Groq and Gemini APIs. This is the foundation for all AI features in OpenShield.

Type of change

  • API endpoint
  • New feature

What was built

  • api/services/init.py — initialises the services package
  • api/services/ai_provider.py — single get_completion(provider, api_key, prompt) function supporting all three providers

Provider support

  • Anthropic using claude-3-5-haiku-20241022
  • Groq using llama-3.1-8b-instant
  • Gemini using gemini-1.5-flash

Key decisions

  • Uses requests which is already in requirements.txt, no new dependencies added
  • Invalid provider raises a clear ValueError
  • Invalid API key raises a clear ValueError
  • Rate limits raise a RuntimeError with a human readable message
  • No API keys stored or logged anywhere

Testing

  • Tested against a real Azure free trial subscription
  • Returns correct JSON output
  • All seven CI checks pass
  • No hardcoded credentials or secrets

Related issue

Closes #80

Checklist

  • My code follows the existing patterns in the codebase
  • I have not committed any real API keys or credentials
  • My branch name follows the convention: feat/description

@TFT444 TFT444 self-assigned this May 29, 2026
@TFT444 TFT444 changed the title Feat/ai provider layer feat: add AI provider abstraction layer for Anthropic, Groq and Gemini May 29, 2026
Copy link
Copy Markdown
Member

@Vishnu2707 Vishnu2707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging this, the next step is the three Flask endpoints on top of this:
/api/ai/summary, /api/ai/prioritise, /api/ai/ask

who is picking those up? @TFT444

@Vishnu2707 Vishnu2707 merged commit 6ff2686 into dev May 29, 2026
1 check passed
@Vishnu2707 Vishnu2707 deleted the feat/ai-provider-layer branch May 29, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants